package main.java.com.lee.procon;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2021/12/20
 */
public class NotSafePCTest {

    private static DataBuffer<String> dataBuffer = new DataBuffer<>();
    public static void main(String[] args) {

        ExecutorService executors = Executors.newFixedThreadPool(20);
        executors.submit(new Producer<>(() -> {
            dataBuffer.put("a");
            return "a";
        }, 200));


        executors.submit(new Consumer<>(() -> {
            dataBuffer.fetch();
            return "a";
        }, 200));

        executors.shutdown();
    }
}
